<template>
    <div>
        本场比赛得分： {{count}}
        <br/>
        <br/>
        <button v-on:click="plusHandler">加分</button>&emsp;
        <button v-on:click="subHandler">减分</button>
        <br/>
        <br/>
        <em>v-on 还有一种简单的写法，就是用@代替</em>
        <br/>
        <br/>
        <button @click="plusHandler">加分</button> &emsp;
        <button @click="subHandler">减分</button>
        <br/>
        <br/>
        <code>键盘回车事件v-on:keyup.enter</code>
        <br/>
        <input type="text" v-on:keyup.enter="onEnterHandler" v-model="secondCount">
    </div>
</template>

<script>
    export default {
        name: 'von',
        data() {
            return {
                count: 0,
                secondCount: 0
            }
        },
        methods: {
            plusHandler() {
                this.count += 1
            },
            subHandler() {
                this.count -= 1
            },
            onEnterHandler: function () {
                this.count = this.count + parseInt(this.secondCount)
            }
        }
    }
</script>
<style scoped>
</style>
